<template>
  <div id="center">
    <div class="up">
      <div
          class="bg-color-black item"
          v-for="item in titleItem"
          :key="item.title"
      >
        <p class="ml-3 colorBlue fw-b fs-xl" style="font-size: 16px">{{ item.title }}</p>
        <div>
          <dv-digital-flop
              class="dv-dig-flop ml-1 mt-2 pl-3"
              :config="item.number"
          />
        </div>
      </div>
    </div>
    <div class="down">
      <div class="ranking bg-color-black">
        <span>
          <icon name="chart-pie" class="text-icon"></icon>
        </span>
        <span class="fs-xl text mx-2 mb-1 pl-3" style="font-size: 16px">厂房设备数量</span>
        <dv-scroll-ranking-board class="dv-scr-rank-board mt-1" :config="ranking"/>
      </div>
      <!--      <div class="percent">-->
      <!--        <div class="item bg-color-black">-->
      <!--          <span>今日任务通过率</span>-->
      <!--          <CenterChart-->
      <!--              :id="rate[0].id"-->
      <!--              :tips="rate[0].tips"-->
      <!--              :colorObj="rate[0].colorData"-->
      <!--          />-->
      <!--        </div>-->
      <!--        <div class="item bg-color-black">-->
      <!--          <span>今日任务达标率</span>-->
      <!--          <CenterChart-->
      <!--              :id="rate[1].id"-->
      <!--              :tips="rate[1].tips"-->
      <!--              :colorObj="rate[1].colorData"-->
      <!--          />-->
      <!--        </div>-->
      <!--        <div class="water">-->
      <!--          <dv-water-level-pond class="dv-wa-le-po" :config="water"/>-->
      <!--        </div>-->
      <!--      </div>-->
    </div>
  </div>
</template>

<script>
// import CenterChart from '@/components/echart/center/centerChartRate'
import {getAllnodestatus} from '@/api/index'

export default {
  async mounted() {
    // const res = await getAllEquipmentNum()
    // const {result: nodeStatus} = await getAllnodestatus()
    getAllnodestatus().then(res => {
      const {result: nodeStatus} = res
      this.titleItem = [
        {
          title: '设备总数',
          number: {
            number: [nodeStatus['total']],
            toFixed: 0,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: '在线设备',
          number: {
            number: [nodeStatus['normalCount']],
            toFixed: 0,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: '掉线设备',
          number: {
            number: [nodeStatus['offlineCount']],
            toFixed: 0,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: '正常设备',
          number: {
            number: [nodeStatus['eventNormalCount']],
            toFixed: 0,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: '告警设备',
          number: {
            number: [nodeStatus['alarmCount']],
            toFixed: 0,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: '故障设备',
          number: {
            number: [nodeStatus['faultCount']],
            toFixed: 0,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        }
      ]
    })
    // getproperty().then(res => {
    //   console.log('res=>', res)
    // })

  },
  data() {
    return {
      titleItem: [],
      ranking: {
        data: [
          {
            name: '电芯厂房',
            value: 614
          },
          {
            name: '动力站',
            value: 69
          },
          {
            name: '凹版',
            value: 31
          },
          {
            name: '原料仓',
            value: 58
          },
          {
            name: '电解液仓',
            value: 21
          },
          {
            name: '水处理站',
            value: 0
          },
          {
            name: '电力监控',
            value: 1288
          },
          {
            name: '拆电池房',
            value: 6
          },
          {
            name: '成品仓',
            value: 13
          }
        ],
        carousel: 'single',
        unit: '台'
      },
      water: {
        data: [24, 45],
        shape: 'roundRect',
        formatter: '{value}%',
        waveNum: 3
      },
      // 通过率和达标率的组件复用数据
      rate: [
        {
          id: 'centerRate1',
          tips: 60,
          colorData: {
            textStyle: '#3fc0fb',
            series: {
              color: ['#00bcd44a', 'transparent'],
              dataColor: {
                normal: '#03a9f4',
                shadowColor: '#97e2f5'
              }
            }
          }
        },
        {
          id: 'centerRate2',
          tips: 40,
          colorData: {
            textStyle: '#67e0e3',
            series: {
              color: ['#faf3a378', 'transparent'],
              dataColor: {
                normal: '#ff9800',
                shadowColor: '#fcebad'
              }
            }
          }
        }
      ]
    }
  },
  components: {
    // CenterChart
  }
}
</script>

<style lang="scss" scoped>
#center {
  display: flex;
  flex-direction: column;

  .up {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;

    .item {
      border-radius: 6px;
      padding-top: 8px;
      margin-top: 8px;
      width: 32%;
      height: 70px;

      .dv-dig-flop {
        width: 150px;
        height: 30px;
      }
    }
  }

  .down {
    padding: 6px 4px;
    padding-bottom: 0;
    width: 100%;
    display: flex;
    height: 255px;
    justify-content: space-between;

    .bg-color-black {
      border-radius: 5px;
    }

    .ranking {
      padding: 10px;
      width: 100%;

      .dv-scr-rank-board {
        height: 225px;
      }
    }

    .percent {
      width: 40%;
      display: flex;
      flex-wrap: wrap;

      .item {
        width: 50%;
        height: 120px;

        span {
          margin-top: 8px;
          font-size: 14px;
          display: flex;
          justify-content: center;
        }
      }

      .water {
        width: 100%;

        .dv-wa-le-po {
          height: 120px;
        }
      }
    }
  }
}
</style>
